﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using IdentityModel.Client;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Http.Features;

namespace WebBClient
{

    public static class HttpRequestExtensions
    {

        /// <summary>
        /// 获取接口绝对路径 http://localhost:5002/ids4/IndexToken
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static string GetAbsoluteUri(this HttpRequest request)
        {
            return new StringBuilder()
                .Append(request.Scheme)
                .Append("://")
                .Append(request.Host)
                .Append(request.PathBase)
                .Append(request.Path)
                .Append(request.QueryString)
                .ToString();
        }

        /// <summary>
        /// 获取接口相对路径 /ids4/IndexToken
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public static string GetRelativeUri(this HttpRequest request)
        {
            //using Microsoft.AspNetCore.Http.Extensions;
            //return HttpContext.Request.GetDisplayUrl();
            return request.Path;
        }

       
    }


}
